package com.aabte.auth.account.domain.model;

import com.aabte.auth.account.domain.service.PasswordService;
import com.aabte.commons.ddd.shared.ValueObject;
import lombok.Getter;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Embeddable;

@SuppressWarnings("all")
@Embeddable
@Getter
@ToString
public class Password implements ValueObject<Password> {

    @Column(name = "account_password")
    private String password;

    private Password() {
    }

    public Password(String password) {
        this.setPassword(password);
    }

    private void setPassword(String password) {
        this.password = password;
    }

    @Override
    public boolean sameValueAs(Password password) {
        return this.password.equals(password.password);
    }

    public static Password encryption(PasswordService passwordService, Password currentPassword) {
        return passwordService.encryption(currentPassword.getPassword());
    }
}
